<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>投票管理</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  {include file="public/css"/}
</head>
<body>
  <div class="layui-fluid">
    <div class="layui-row layui-col-space15">
      <div class="layui-card layui-col-md12">
				<div class="layui-card-header">
					{if !$info['id']}<i class="fa fa-plus"></i> 添加投票{else}<i class="fa fa-pencil"></i> 编辑投票{/if}
					<i class="layui-icon layui-icon-close" style="font-size:18px;font-weight:bold;cursor:pointer" onclick="closeself()"></i>
				</div>
				<div class="layui-card-body" pad15>
					<div class="layui-form">
						<input type="hidden" name="id" value="{$info.id}"/>
						<div class="layui-form-item">
							<label class="layui-form-label">活动名称：</label>
							<div class="layui-input-inline" style="width:300px">
								<input type="text" name="info[name]" lay-verify="required" lay-verType="tips" class="layui-input" value="{$info.name}">
							</div>
						</div>
						<div class="layui-form-item">
							<label class="layui-form-label">顶部图片：</label>
							<input type="hidden" name="info[banner]" id="banner" lay-verType="tips" class="layui-input" value="{$info.banner}">
							<button style="float:left;" type="button" class="layui-btn layui-btn-primary" upload-input="banner" upload-preview="bannerPreview" onclick="uploader(this)">上传图片</button>
							<div class="layui-form-mid layui-word-aux" style="margin-left:10px;">建议尺寸：640×320像素，png格式</div>
							<div id="bannerPreview" style="float:left;padding-top:10px;padding-left:110px;clear: both;">
								<div class="layui-imgbox" style="width:100px;"><div class="layui-imgbox-img"><img src="{$info.banner}"/></div></div>
							</div>
						</div>
						<div class="layui-form-item">
							<label class="layui-form-label">背景颜色：</label>
							<div class="layui-input-inline">
								<input type="text" name="info[color1]" value="{$info['color1']}" class="layui-input">
							</div>
							<div class="_colorpicker" style="float:left"></div>
							<div class="layui-form-mid layui-word-aux" style="margin-left:10px;">页面背景颜色，如：#FD4A46</div>
						</div>
						<div class="layui-form-item">
							<label class="layui-form-label">字体颜色：</label>
							<div class="layui-input-inline">
								<input type="text" name="info[color2]" value="{$info['color2']}" class="layui-input">
							</div>
							<div class="_colorpicker" style="float:left"></div>
							<div class="layui-form-mid layui-word-aux" style="margin-left:10px;">页面文本颜色，如：#1C83FF</div>
						</div>
						<div class="layui-form-item">
							<label class="layui-form-label">选手列表：</label>
							<div class="layui-input-inline" style="width:500px">
								<input type="radio" name="info[listtype]" title="双排" value="0" {if $info['listtype']==0}checked{/if}/>
								<input type="radio" name="info[listtype]" title="横排" value="1" {if $info['listtype']==1}checked{/if}/>
							</div>
						</div>
						<div class="layui-form-item">
							<label class="layui-form-label">投票文字：</label>
							<div class="layui-input-inline" style="width:300px">
								<input type="text" name="info[helptext]" lay-verify="required" lay-verType="tips" class="layui-input" value="{$info.helptext}">
							</div>
							<div class="layui-form-mid layui-word-aux">如：投TA一票、给TA点赞</div>
						</div>
						<div class="layui-form-item">
							<label class="layui-form-label">开始时间：</label>
							<div class="layui-input-inline">
								<input type="text" id="starttime" name="info[starttime]" value="{:date('Y-m-d H:i:s',$info['starttime'])}" class="layui-input">
							</div>
						</div>
						<div class="layui-form-item">
							<label class="layui-form-label">结束时间：</label>
							<div class="layui-input-inline">
								<input type="text" id="endtime" name="info[endtime]" value="{:date('Y-m-d H:i:s',$info['endtime'])}" class="layui-input">
							</div>
						</div>
						<div class="layui-form-item">
							<label class="layui-form-label">每天可投：</label>
							<div class="layui-input-inline">
								<input type="text" name="info[per_daycount]" value="{$info.per_daycount}" class="layui-input">
							</div>
							<div class="layui-form-mid">票</div>
							<div class="layui-form-mid layui-word-aux">每人每天可投票数</div>
						</div>
						<div class="layui-form-item">
							<label class="layui-form-label">总计可投：</label>
							<div class="layui-input-inline">
								<input type="text" name="info[per_allcount]" value="{$info.per_allcount}" class="layui-input">
							</div>
							<div class="layui-form-mid">票</div>
							<div class="layui-form-mid layui-word-aux">每人最多可投票数，0表示不限制</div>
						</div>
						<div class="layui-form-item">
							<label class="layui-form-label">用户报名：</label>
							<div class="layui-input-inline">
								<input type="radio" name="info[canapply]" title="开启" value="1" {if $info['canapply']==1}checked{/if} lay-filter="canapply"/>
								<input type="radio" name="info[canapply]" title="关闭" value="0" {if $info['canapply']==0}checked{/if} lay-filter="canapply"/>
							</div>
						</div>
						<div class="layui-form-item" style="{if $info['canapply']==0}display:none{/if}" id="canapply_div">
							<label class="layui-form-label">报名审核：</label>
							<div class="layui-input-inline">
								<input type="radio" name="info[apply_check]" title="开启" value="1" {if $info['apply_check']==1}checked{/if}/>
								<input type="radio" name="info[apply_check]" title="关闭" value="0" {if $info['apply_check']==0}checked{/if}/>
							</div>
						</div>
						<div class="layui-form-item">
							<label class="layui-form-label">投票验证：</label>
							<div class="layui-input-inline" style="width:500px">
								<input type="radio" name="info[help_check]" title="不需要验证" value="0" {if $info['help_check']==0}checked{/if}/>
								<input type="radio" name="info[help_check]" title="图片验证码" value="1" {if $info['help_check']==1}checked{/if}/>
								<input type="radio" name="info[help_check]" title="短信验证码" value="2" {if $info['help_check']==2}checked{/if}/>
							</div>
						</div>
						<div class="layui-form-item">
							<label class="layui-form-label" style="width:110px">参与条件：</label>
							<div class="layui-input-inline" style="width:60%">
								<input type="checkbox" name="info[gettj][]" value="-1" title="所有人" {if in_array('-1',$info['gettj'])}checked{/if}/>
								<input type="checkbox" name="info[gettj][]" value="0" title="关注用户" {if in_array('0',$info['gettj'])}checked{/if}/>
								{foreach $memberlevel as $v}
								<input type="checkbox" name="info[gettj][]" value="{$v.id}" title="{$v.name}" {if in_array($v['id'],$info['gettj'])}checked{/if}/>
								{/foreach}
							</div>
						</div>
						<div class="layui-form-item">
							<label class="layui-form-label">序号：</label>
							<div class="layui-input-inline">
								<input type="text" name="info[sort]" value="{$info.sort|default='0'}" class="layui-input">
							</div>
							<div class="layui-form-mid layui-word-aux">用于排序,越大越靠前</div>
						</div>
						<div class="layui-form-item">
							<label class="layui-form-label">活动规则</label>
							<div class="layui-input-inline" style="width:500px">
								<script id="guize" name="info[guize]" type="text/plain" style="width:100%;height:400px">{$info.guize}</script>
							</div>
						</div>
						<div class="layui-form-item">
							<label class="layui-form-label">状态：</label>
							<div class="layui-input-inline" style="width:500px">
								<input type="radio" name="info[status]" title="开启" value="1" {if $info['status']==1}checked{/if}/>
								<input type="radio" name="info[status]" title="关闭" value="0" {if $info['status']==0}checked{/if}/>
							</div>
						</div>
						分享设置<hr/>
						<div class="layui-form-item">
							<label class="layui-form-label">分享标题：</label>
							<div class="layui-input-inline" style="width:300px">
								<input type="text" class="layui-input" name="info[sharetitle]" value="{$info.sharetitle}"/>
							</div>
							<div class="layui-form-mid layui-word-aux">默认为活动名称</div>
						</div>
						<div class="layui-form-item">
							<label class="layui-form-label">分享图标：</label>
							<input type="hidden" name="info[sharepic]" id="sharepic" lay-verType="tips" class="layui-input" value="{$info.sharepic}">
							<button style="float:left;" type="button" class="layui-btn layui-btn-primary" upload-input="sharepic" upload-preview="sharepicPreview" onclick="uploader(this)">上传图片</button>
							<div class="layui-form-mid layui-word-aux" style="margin-left:10px;">建议尺寸：400*400像素</div>
							<div id="sharepicPreview" style="float:left;padding-top:10px;padding-left:110px;clear: both;">
								<div class="layui-imgbox" style="width:100px;"><div class="layui-imgbox-img"><img src="{$info.sharepic}"/></div></div>
							</div>
						</div>
						<div class="layui-form-item">
							<label class="layui-form-label">分享描述：</label>
							<div class="layui-input-inline" style="width:300px">
								<input type="text" class="layui-input" name="info[sharedesc]" value="{$info.sharedesc}"/>
							</div>
							<div class="layui-form-mid layui-word-aux"></div>
						</div>
						<div class="layui-form-item">
							<label class="layui-form-label">分享链接：</label>
							<div class="layui-input-inline" style="width:300px">
								<input type="text" class="layui-input" name="info[sharelink]" value="{$info.sharelink}"/>
							</div>
							<div class="layui-form-mid layui-word-aux">默认为活动链接，设置后发送给朋友或分享到朋友圈，点击后会跳转到此链接地址</div>
						</div>
						<div class="layui-form-item">
							<div class="layui-input-block">
								<button class="layui-btn layui-btn-danger" lay-submit lay-filter="formsubmit">提 交</button>
							</div>
						</div>
					</div>
				</div>
			</div>
    </div>
  </div>
	{include file="public/js"/}
	<script>
	var guize = UE.getEditor('guize',{imageScaleEnabled:false});
	layui.form.on('radio(canapply)', function(data){
		if(data.value == '0'){
			$('#canapply_div').hide();
		}else if(data.value == '1'){
			$('#canapply_div').show();
		}
	})
	//日期时间选择器
	layui.laydate.render({ 
		elem: '#starttime',
		type: 'datetime',
		trigger: 'click'
	});
	layui.laydate.render({ 
		elem: '#endtime',
		type: 'datetime',
		trigger: 'click'
	});

	layui.form.on('submit(formsubmit)', function(obj){
		var field = obj.field
		field['info[guize]'] = guize.getContent();
		var index = layer.load();
		$.post("{:url('save')}",field,function(data){
			layer.close(index);
			dialog(data.msg,data.status);
			if(data.status == 1){
				setTimeout(function(){
					parent.layer.closeAll();
					parent.tableIns.reload()
				},1000)
			}
		})
	})
	</script>
	{include file="public/copyright"/}
</body>
</html>